package cn.enited.devtools.apiaggregator.exception;

import cn.enited.devtools.apiaggregator.consts.ErrorCode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ToString(callSuper = true)
public class BizException extends RuntimeException {
    private static final long serialVersionUID = 8823731724422796344L;

    private Integer errorCode;

    public BizException() {
        super(ErrorCode.ERROR.message());
        this.errorCode = ErrorCode.ERROR.code();
    }

    public BizException(ErrorCode errorCode) {
        super(errorCode.message());
        this.errorCode = errorCode.code();
    }

    public BizException(Integer errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public BizException(ErrorCode errorCode, Throwable cause) {
        super(ErrorCode.ERROR.message(), cause);
        this.errorCode = errorCode.code();
    }

    public BizException(Throwable cause) {
        super(cause);
        this.errorCode = ErrorCode.ERROR.code();
    }
}
